class Solution:
    def searchRange(self, nums: list[int], target: int) -> list[int]:
        ans_right = Left(nums,target)
        ans_left = Right(nums,target)
        if ans_left == 0 and ans_right == len(nums):
            return [-1,-1]
        else:
            return [ans_left,ans_right]



def Right(nums,target:int) -> int:
    # 大于等于x的最小下标
    left = 0
    ans = len(nums)
    right = len(nums)-1
    while left<=right:
        midd = (left+right) // 2
        if nums[midd] >= target:
            right = midd-1
            ans = midd
        else:
            left = midd +1
    return ans

def Left(nums,target:int) ->int:
    # 小于等于x的最大下标    
    left = 0
    right = len(nums)-1
    ans = 0
    while left<=right:
        midd = (left+right) // 2
        if nums[midd] <= target:
            left = midd+1
            ans = midd
        else:
            right = midd - 1
    return ans
        
s= Solution()
result = s.searchRange(nums = [5,7,7,8,8,10], target = 6)

print(result)